package com.zycfc.zsf.boot.util.xml;

import javax.xml.bind.*;
import java.io.*;

public class XmlUtil
{
    public static String toXml(final Object obj) {
        final StringWriter sw = new StringWriter();
        JAXB.marshal(obj, sw);
        return sw.toString();
    }
    
    public static <T> T parseXml(final String xml, final Class<T> tClass) {
        final StringReader sr = new StringReader(xml);
        return JAXB.unmarshal(sr, tClass);
    }
}
